<%-- 
    Document   : ingresar_entrada
    Created on : 16-mar-2013, 12:31:33
    Author     : DEMRR
--%>

<%@page import="bdclass.UnidadMedida"%>
<%@page import="bdclass.Sucursal"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="bdclass.Ingrediente"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<%!String ingrediente;%>
<%int id;%>

<html>
    <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
                <meta name="description" content="Expand, contract, animate forms with jQuery wihtout leaving the page" />
                <meta name="keywords" content="expand, form, css3, jquery, animate, width, height, adapt, unobtrusive javascript"/>
                <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon"/>
                <link rel="stylesheet" type="text/css" href="css/log/style.css" />		
				<link href="http://fonts.googleapis.com/css?family=Arvo" rel="stylesheet" type="text/css" />
				<link href="css/style in.css" rel="stylesheet" type="text/css" media="screen" />		
				
        <title>Registro de Entradas</title>
    </head>
    <body>
	<div id="wrapper">
	<div id="header">
		<div id="logo">
			<img src="images/logo-sm-main.png"/>
		</div>
	</div>
	</div>
        
        
        <form id="form1" name="form1" method="post" action="">
            <div align="center" style="margin-left:100px; margin-right:100px; margin-top:50px;">
                <table width="70%" border="1" bgcolor="#FFFFFF">
                <tr>
                    <td colspan="2" style="margin-top:10px;"><div align="center">
                    <h2><strong>REGISTRO DE ENTRADA DE INGREDIENTES</strong></h2>
                    </div></td>
                  </tr>
                <tr>
                    <td colspan="2"><h3>Ingresar por:</h3></td>
                </tr>
                <tr>
                    <td width="50%"><label>
                    <div align="center"><p>
                        <input type="radio" name="optIngresar" value="1"/>
                        Codigo de Ingrediente</p></div>
                    </label></td>
                    <td width="50%"><label>
                    <div align="center"><p>
                        <input type="radio" name="optIngresar" value="2"/>
                        Nombre de Ingrediente</p></div>
                    </label></td>
                </tr>
                <tr>
                    <td colspan="2"><div align="center">
                    <input type="submit" name="btnok" id="btnok" value="ACEPTAR" />
                    </div></td>
                </tr>
              </table>
            </div>
         </form>
        
        
        <%
        try
           {
            
                Class.forName("org.postgresql.Driver").newInstance();
                Ingrediente ing=new Ingrediente();
                ResultSet rs=ing.SelectIngrediente();
                
                while(rs.next())
                if(request.getParameter("btnok")!=null)
                    {
                        if (Integer.parseInt(String.valueOf(request.getParameter("optIngresar")))==1)
                            {%>
								<div align="center" style="margin-left:100px; margin-right:100px; margin-top:10px;">
                                <form id="form2" name="form1" method="post" action="confirmacionEntrada.jsp">
								
                                    <table width="70%" border="0" align="center" bgcolor="#FFFFFF">
                                    
                                    
                                    <tr>
                                        <td width="50%">
                                        <p>CODIGO: DE INGREDIENTE</p>
                                        </td>
                                    <td width="55" colspan="2" align="left"><label for="txtcompania">
                                        <select name="cmbIngrediente" id="cmbIngrediente">
                                            <%
                                            while(rs.next())
                                            {
                                                id=rs.getInt("id_ingrediente");
                                                ingrediente=rs.getString("cod_ingrediente");
                                                
                                            %>
                                                <option value="<%=id%>"><%=ingrediente%></option>
                                            <%}
                                            %>
                                        </select>
                                    </label></td>
                                    </tr>

                                    
                                    <tr>
                                      <td>&nbsp;</td>
                                      <td colspan="2" align="left">&nbsp;</td>
                                    </tr>
                                    <tr>
                                      <td>CANTIDAD:</td>
                                      <td align="left"><label for="textfield"></label>
                                      <input type="text" name="txtCantidad"/></td>
                                      <td>UNIDAD DE MEDIDA</td>
                                    </tr>
                                    <tr>
                                      <td>SUCURSAL:</td>
                                      <td colspan="2" align="left"><select name="cmbSucursal" id="cmbSucursal">
                                        <%
                                            Sucursal suc= new Sucursal();
                                            ResultSet rs2=suc.SelectSucursal();
                                            while(rs2.next())
                                            {               
                                                
                                            %>
                                        <option value="<%=rs2.getInt("id_sucursal")%>"><%=rs2.getString("nombre_sucursal")%></option>
                                        <%}
                                            %>
                                      </select></td>
                                    </tr>
                                    <tr>
                                      <td>&nbsp;</td>
                                      <td colspan="2" align="left">&nbsp;</td>
                                    </tr>
                                    <tr>
                                      <td>INGRESADO POR:</td>
                                      <td colspan="2" align="left"><label>Empleado</label>&nbsp;</td>
                                    </tr>
                                    <tr>
                                      <td>&nbsp;</td>
                                      <td colspan="2">&nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td colspan="3" width="50%"><div align="center">
                                        <input type="submit" name="btnok" id="btnok2" value="ACEPTAR"/>
                                        </div></td>
                                      </tr>

                                  </table>
                                    <label for="txtid"></label>
                        </form>
							</div>
                            <%}
                        else
                            {%>
                 <div align="center" style="margin-left:100px; margin-right:100px; margin-top:10px;">              
				<form id="form2" name="form1" method="post" action="confirmacionEntrada.jsp">
				
                                    <table  width="70%" border="0" align="center" bgcolor="#FFFFFF">
                                    
                                    
                                    <tr>
                                        <td width="308">
                                        <p>INGREDIENTE:</p>
                                      </td>
                                    <td colspan="2" align="left"><label for="txtcompania">
                                        <select name="cmbIngrediente" id="cmbIngrediente">
                                            <%
                                            while(rs.next())
                                            {
                                                id=rs.getInt("id_ingrediente");
                                                ingrediente=rs.getString("nombre");
                                                
                                            %>
                                                <option value="<%=id%>"><%=ingrediente%></option>
                                            <%}
                                            %>
                                        </select>
                                    </label></td>
                                    </tr>

                                    
                                    <tr>
                                      <td>&nbsp;</td>
                                      <td colspan="2" align="left">&nbsp;</td>
                                    </tr>
                                    <tr>
                                      <td>CANTIDAD:</td>
                                      <td width="146" align="left"><label for="textfield"></label>
                                      <input type="text" name="txtCantidad"/></td>
                                      <td width="110">UNIDAD DE MEDIDA</td>
                                    </tr>
                                    <tr>
                                      <td>SUCURSAL:</td>
                                      <td colspan="2" align="left"><select name="cmbSucursal" id="cmbSucursal">
                                        <%
                                            Sucursal suc= new Sucursal();
                                            ResultSet rs2=suc.SelectSucursal();
                                            while(rs2.next())
                                            {               
                                                
                                            %>
                                        <option value="<%=rs2.getInt("id_sucursal")%>"><%=rs2.getString("nombre_sucursal")%></option>
                                        <%}
                                            %>
                                      </select></td>
                                    </tr>
                                    <tr>
                                      <td>&nbsp;</td>
                                      <td colspan="2" align="left">&nbsp;</td>
                                    </tr>
                                    <tr>
                                      <td>INGRESADO POR:</td>
                                      <td colspan="2" align="left"><label>Empleado</label>&nbsp;</td>
                                    </tr>
                                    <tr>
                                      <td>&nbsp;</td>
                                      <td colspan="2">&nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td colspan="3"><div align="center">
                                        <input type="submit" name="btnok" id="btnok2" value="ACEPTAR"/>
                                      </div></td>
                                      </tr>

                  </table>
                                    <label for="txtid"></label>
    </form>
						</div>				
        <%}
                    }
                
            }
            catch (Exception ex) {
            System.out.println(ex.toString());
        }
        %>
        
        
    </body>
</html>
